package cn.com.sinux.spring.commons;

import org.springframework.data.domain.Sort;

import java.util.LinkedList;
import java.util.List;

/**
 * Created by Administrator on 2016/2/18.
 */
public class OrderCollection {

    private List<Sort.Order> orders;

    public List<Sort.Order> getOrders() {
        return orders;
    }

    public void setOrders(List<Sort.Order> orders) {
        this.orders = orders;
    }

    public OrderCollection(){
        orders = new LinkedList<Sort.Order>();
    }

    public OrderCollection addOrder(Sort.Direction direction, String property){
        orders.add(new Sort.Order(direction, property));
        return this;
    }

    public OrderCollection addOrder(Sort.Order order){
        if(order != null){orders.add(order);}
        return this;
    }
}
